package com.kly.sc.api.application.utils;

import com.kly.sc.api.infras.enums.RestCodeEnum;
import com.kly.sc.api.infras.exception.ApplicationException;
import org.springframework.util.StringUtils;

/**
 * 参数检验类
 * @author linqu
 */
public class ValidateParams {

    public static void notEmpty(String str, String errorMsg) throws ApplicationException {
        if (str == null || StringUtils.isEmpty(str.trim())) {
            throw new ApplicationException(RestCodeEnum.SYSTEM_PARAMETER_ERROR, errorMsg);
        }
    }

    public static void assertTrue(boolean flag, String errorMsg) throws ApplicationException {
        if (flag) {
            throw new ApplicationException(errorMsg);
        }
    }

}
